﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Test
{
    [TestClass]
    public class UnitTest1
    {
        [TestMethod]
        public void TestMethod1()
        {
            var item = new
            {
                a=1,
                b="1",
            };
            var a = cast(item);
            a.Add(new {a=1,b=""});
            var list=new List<dynamic>();
            list.Add(item);
            list.Add(1);
            list.Add("s");
            var t=list[0];
            
            var arrstr = new[]
            {
                new { username = "test1", userpwd = "123456" },
                new { username = "test2", userpwd = "987654" }
            };
           var s= arrstr.ToList();

        }
        List<T> cast<T>(T t)
        {
            var list=new List<T>();
            return list;
        }

        [TestMethod]
        public  void Regex()
        {
            string s1 = "所属机构名称/教师姓名/课程类型/课程名称-vbcvbcvbcvb";
            var s2 = "Length:2000\r\nasdasd16fv6gh1f6g1";
            //定义一个能够将我们需要的东西截取出来的正则表达式  
            Regex regex = new Regex(@"(.*)/(.*)/(.*)/(.*)", RegexOptions.IgnoreCase);
            regex=new Regex(@"Length:(.*)\r\n.*");
            //显示每一个满足正则表达式的子字符串  
            foreach (var i in regex.Match(s2).Groups)
            {
                Console.WriteLine(i);
            }
        }
    }
}
